package com.supply.service.impl;

import com.supply.mapper.ProcurementBillMapper;
import com.supply.pojo.ProcurementBill;
import com.supply.pojo.ProcurementBillExample;
import com.supply.service.ProcurementBillService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProcurementBillServiceImpl implements ProcurementBillService {
    @Autowired
    private ProcurementBillMapper procurementBillMapper;

    @Override
    public ProcurementBill queryById(Long id) {
        return procurementBillMapper.selectByPrimaryKey(id);
    }

    @Override
    public int saveOrUpdate(ProcurementBill procurementBill) {
        if (procurementBill.getId() == null){
            return procurementBillMapper.insert(procurementBill);
        }else {
            return procurementBillMapper.updateByPrimaryKey(procurementBill);
        }
    }

    @Override
    public List<ProcurementBill> queryByUserId(long id) {
        ProcurementBillExample example = new ProcurementBillExample();
        example.createCriteria().andUserIdEqualTo(id);
        return procurementBillMapper.selectByExample(example);
    }

    @Override
    public List<ProcurementBill> queryAll() {
        return procurementBillMapper.selectByExample(null);
    }

    @Override
    public int deleteById(Long id) {
        return procurementBillMapper.deleteByPrimaryKey(id);
    }
}
